
package com.platform.modules.mall.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.platform.common.annotation.SysLog;
import com.platform.common.utils.RestResponse;
import com.platform.modules.mall.entity.MallModuleEntity;
import com.platform.modules.mall.service.MallModuleService;
import com.platform.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 模块表Controller
 *
 * @author 
 * @date 2021-06-22 11:41:22
 */
@RestController
@RequestMapping("mall/module")
public class MallModuleController extends AbstractController {
    @Autowired
    private MallModuleService mallModuleService;

    /**
     * 查看所有列表
     *
     * @param params 查询参数
     * @return RestResponse
     */
    @RequestMapping("/queryAll")
    @RequiresPermissions("mall:module:list")
    public RestResponse queryAll(@RequestParam Map<String, Object> params) {
        List<MallModuleEntity> list = mallModuleService.queryAll(params);

        return RestResponse.success().put("list", list);
    }

    /**
     * 分页查询模块表
     *
     * @param params 查询参数
     * @return RestResponse
     */
    @GetMapping("/list")
    @RequiresPermissions("mall:module:list")
    public RestResponse list(@RequestParam Map<String, Object> params) {
        Page page = mallModuleService.queryPage(params);

        return RestResponse.success().put("page", page);
    }

    /**
     * 根据主键查询详情
     *
     * @param id 主键
     * @return RestResponse
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("mall:module:info")
    public RestResponse info(@PathVariable("id") String id) {
        MallModuleEntity mallModule = mallModuleService.getById(id);

        return RestResponse.success().put("module", mallModule);
    }

    /**
     * 新增模块表
     *
     * @param mallModule mallModule
     * @return RestResponse
     */
    @SysLog("新增模块表")
    @RequestMapping("/save")
    @RequiresPermissions("mall:module:save")
    public RestResponse save(@RequestBody MallModuleEntity mallModule) {

        mallModuleService.add(mallModule);

        return RestResponse.success();
    }

    /**
     * 修改模块表
     *
     * @param mallModule mallModule
     * @return RestResponse
     */
    @SysLog("修改模块表")
    @RequestMapping("/update")
    @RequiresPermissions("mall:module:update")
    public RestResponse update(@RequestBody MallModuleEntity mallModule) {

        mallModuleService.update(mallModule);

        return RestResponse.success();
    }

    /**
     * 根据主键删除模块表
     *
     * @param ids ids
     * @return RestResponse
     */
    @SysLog("删除模块表")
    @RequestMapping("/delete")
    @RequiresPermissions("mall:module:delete")
    public RestResponse delete(@RequestBody String[] ids) {
        mallModuleService.deleteBatch(ids);

        return RestResponse.success();
    }
}
